//变量声明
var myCanvas = document.getElementById("myCanvas");
var ctx = myCanvas.getContext("2d");
var text = "点击进入游戏";
//进度条初始长度,坐标
var length = 0,
    barX = 200,
    barY = myCanvas.height / 2,
    count = 0;
//函数定义
//绘制进度条
drawBar = function () {
    length += 4;
    count++;
    clearCanvas();
    ctx.beginPath();
    ctx.fillStyle = "skyBlue";
    ctx.font = "14px serif";
    ctx.fillRect(barX, barY, length, 20);
    ctx.beginPath();
    ctx.fillStyle = "white";
    ctx.fillText(count + "%", barX + 15, barY + 10);
    if (length < 400) {
        requestAnimationFrame(drawBar);
    } else {
        init();
    }
}
//事件
myCanvas.onmousedown = function (e) {
    if (game_over == 0 && game_success == 0) {
        clearCanvas();
        drawBar();
        init();
    }

}
//初始化
ctx.font = "bold 60px serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#fff";
ctx.fillText(text, myCanvas.width / 2, myCanvas.height / 2);